package com.example.PDFdemo.pdffinalplan;

import com.itextpdf.text.DocumentException;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;

public class Test {
    public static void main(String[] args) throws DocumentException, IOException {
        String oldFilePath = "C:\\Users\\admin\\Desktop\\test1.pdf";
        String newFilePath = "C:\\Users\\admin\\Desktop\\test2.pdf";
        FileInputStream fis = new FileInputStream("C:\\Users\\admin\\Desktop\\1.jpeg");
        //byte[] imgurles = DatatypeConverter.parseBase64Binary("QzpcVXNlcnNcYWRtaW5cRGVza3RvcFwxLmpwZWc=");
        ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
        BufferedImage bufferedImage = null;
        byte[] imgurles = new byte[0];
        try {
            bufferedImage = ImageIO.read(new File("C:\\Users\\admin\\Desktop\\1.jpeg"));
            ImageIO.write(bufferedImage, "jpg", byteOutput);
            imgurles = byteOutput.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (byteOutput != null)
                    byteOutput.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        List<PDFModel> models = new ArrayList<>();
        //models.add(new PDFModel(100f, 80f, 0f, 0f, 1, "正正正正正正正正正正正正正正正正正正正正正正正正", "宋体", 20f, 1, 2, 16f, 1, 0, color1, null));
        models.add(new PDFModel(0.168328127630127f, 0.01875f, 0.15875f, 0.9735109060402685f, 1, "撒大大阿达", "宋体", 10f, 0, 0, 10f, 1, 5, "#000000", null));
        models.add(new PDFModel(0.168328127630127f, 0.054744127516778526f,  0.6525f, 0.445494966442953f, 2, null, null, null, null, null, null, null, null, null, imgurles));
        Finalyplan.addText(oldFilePath, newFilePath, models);


    }
}
